Generates the pair-difference chi-squared statistic for each point in a data set, summing over scaled differences frm other points.
pdchisq(x, s=sd, cov=NULL, cor = NULL, na.rm=FALSE, ...)An object of class "PDchisq", consisting of a vector of length length(x) of median
scaled absolute deviations for each observation, with attributes:
character vector of names, taken from x
values supplied as x
values supplied as s
Print and plotting methods are provided for the “PDchisq” class;
see PDchisq-class.
Vector of observations
Either a function returning an estimate of scale for x or a vector of
length length(x) of standard errors or standard uncertainties in x.
Covariance or correlation matrix, respectively, describing the covariance structure
across x.
logical. Controls whether missing values should be removed.
NOTE: na.rm is passed to s as well as sum;
s must accordingly accept an argument na.rm.
Parameters passed to s if s is a function.
S. L. R. Ellison s.ellison@lgcgroup.com
For each observation \(x_j\), pdchisq calculates the pairwise chi-squared statistic
$$\chi_{j \rm PD}^2 = \frac{1}{N-1} \sum_{i=1}^{N} (x_i - x_j)^2/(s_i^2 + s_j^2 - 2 {\rm cov}(x_i, x_j)) $$
that is, the sum of squared differences divided by the estimated uncertainties of the distances.
If s is a function, it is applied to x and replicated to length
length(x). Note that na.rm is passed to s, so
s must accept an argument na.rm. For some scale
functions that may require s to be defined as a wrapper to
avoid unused argument warnings. For example, if foo is a scale
function that does not accept an na.rm argument, use
s=function(x, na.rm, ...) foo(x, ...) .
If s is a scalar, it is replicated to length length(x).
If cov is present, s is silently ignored.
If cor is present, cov is constructed from cor and s
The pair-difference chi-squared statistic is a measure of how ‘far’ an individual observation is from all the other values in the data set, taking account of uncertainties.
R J Douglas, A G Steele (2006) Pair-difference chi-squared statistics for Key Comparisons, Metrologia 43, 89-97
PDchisq-class, bootPDchisq.
data(Pb)
pdchisq(Pb$value) # Uses mad(Pb$value) as scale estimate
pdchisq(Pb$value, Pb$u) # Scales differences using standard uncertainties
Run the code above in your browser using DataLab